import Foundation

@objcMembers
public class FotoUtil {
    public static var DAY_ZHAI_GUAN_YIN: [String] = ["1-8", "2-7", "2-9", "2-19", "3-3", "3-6", "3-13", "4-22", "5-3", "5-17", "6-16", "6-18", "6-19", "6-23", "7-13", "8-16", "9-19", "9-23", "10-2", "11-19", "11-24", "12-25"]
    public static var XIU_27: [String] = ["角", "亢", "氐", "房", "心", "尾", "箕", "斗", "女", "虚", "危", "室", "壁", "奎", "娄", "胃", "昴", "毕", "觜", "参", "井", "鬼", "柳", "星", "张", "翼", "轸"]
    public static var XIU_OFFSET: [Int] = [11, 13, 15, 17, 19, 21, 24, 0, 2, 4, 7, 9]
    private static var dj = "犯者夺纪"
    private static var js = "犯者减寿"
    private static var ss = "犯者损寿"
    private static var xl = "犯者削禄夺纪"
    private static var jw = "犯者三年内夫妇俱亡"
    private static var y: [String] = ["杨公忌"]
    private static var t: [String] = ["四天王巡行", "", "true"]
    private static var d: [String] = ["斗降", dj, "true"]
    private static var s: [String] = ["月朔", dj, "true"]
    private static var w: [String] = ["月望", dj, "true"]
    private static var h: [String] = ["月晦", js, "true"]
    private static var l: [String] = ["雷斋日", js, "true"]
    private static var j: [String] = ["九毒日", "犯者夭亡，奇祸不测"]
    private static var r: [String] = ["人神在阴", "犯者得病", "true", "宜先一日即戒"]
    private static var m: [String] = ["司命奏事", js, "true", "如月小，即戒廿九"]
    private static var hh: [String] = ["月晦", js, "true", "如月小，即戒廿九"]

    public static var FESTIVAL: [String: [[String]]] = [
        "1-1": [["天腊，玉帝校世人神气禄命", xl], s],
        "1-3": [["万神都会", dj], d],
        "1-5": [["五虚忌"]],
        "1-6": [["六耗忌"], l],
        "1-7": [["上会日", ss]],
        "1-8": [["五殿阎罗天子诞", dj], t],
        "1-9": [["玉皇上帝诞", dj]],
        "1-13": [y],
        "1-14": [["三元降", js], t],
        "1-15": [["三元降", js], ["上元神会", dj], w, t],
        "1-16": [["三元降", js]],
        "1-19": [["长春真人诞"]],
        "1-23": [["三尸神奏事"], t],
        "1-25": [h, ["天地仓开日", "犯者损寿，子带疾"]],
        "1-27": [d],
        "1-28": [r],
        "1-29": [t],
        "1-30": [hh, m, t],
        "2-1": [["一殿秦广王诞", dj], s],
        "2-2": [["万神都会", dj], ["福德土地正神诞", "犯者得祸"]],
        "2-3": [["文昌帝君诞", xl], d],
        "2-6": [["东华帝君诞"], l],
        "2-8": [["释迦牟尼佛出家", dj], ["三殿宋帝王诞", dj], ["张大帝诞", dj], t],
        "2-11": [y],
        "2-14": [t],
        "2-15": [["释迦牟尼佛涅槃", xl], ["太上老君诞", xl], ["月望", xl, "true"], t],
        "2-17": [["东方杜将军诞"]],
        "2-18": [["四殿五官王诞", xl], ["至圣先师孔子讳辰", xl]],
        "2-19": [["观音大士诞", dj]],
        "2-21": [["普贤菩萨诞"]],
        "2-23": [t],
        "2-25": [h],
        "2-27": [d],
        "2-28": [r],
        "2-29": [t],
        "2-30": [hh, m, t],
        "3-1": [["二殿楚江王诞", dj], s],
        "3-3": [["玄天上帝诞", dj], d],
        "3-6": [l],
        "3-8": [["六殿卞城王诞", dj], t],
        "3-9": [["牛鬼神出", "犯者产恶胎"], y],
        "3-12": [["中央五道诞"]],
        "3-14": [t],
        "3-15": [["昊天上帝诞", dj], ["玄坛诞", dj], w, t],
        "3-16": [["准提菩萨诞", dj]],
        "3-19": [["中岳大帝诞"], ["后土娘娘诞"], ["三茅降"]],
        "3-20": [["天地仓开日", ss], ["子孙娘娘诞"]],
        "3-23": [t],
        "3-25": [h],
        "3-27": [["七殿泰山王诞"], d],
        "3-28": [r, ["苍颉至圣先师诞", xl], ["东岳大帝诞"]],
        "3-29": [t],
        "3-30": [hh, m, t],
        "4-1": [["八殿都市王诞", dj], s],
        "4-3": [d],
        "4-4": [["万神善会", "犯者失瘼夭胎"], ["文殊菩萨诞"]],
        "4-6": [l],
        "4-7": [["南斗、北斗、西斗同降", js], y],
        "4-8": [["释迦牟尼佛诞", dj], ["万神善会", "犯者失瘼夭胎"], ["善恶童子降", "犯者血死"], ["九殿平等王诞"], t],
        "4-14": [["纯阳祖师诞", js], t],
        "4-15": [w, ["钟离祖师诞"], t],
        "4-16": [["天地仓开日", ss]],
        "4-17": [["十殿转轮王诞", dj]],
        "4-18": [["天地仓开日", ss], ["紫徽大帝诞", ss]],
        "4-20": [["眼光圣母诞"]],
        "4-23": [t],
        "4-25": [h],
        "4-27": [d],
        "4-28": [r],
        "4-29": [t],
        "4-30": [hh, m, t],
        "5-1": [["南极长生大帝诞", dj], s],
        "5-3": [d],
        "5-5": [["地腊", xl], ["五帝校定生人官爵", xl], j, y],
        "5-6": [j, l],
        "5-7": [j],
        "5-8": [["南方五道诞"], t],
        "5-11": [["天地仓开日", ss], ["天下都城隍诞"]],
        "5-12": [["炳灵公诞"]],
        "5-13": [["关圣降", xl]],
        "5-14": [["夜子时为天地交泰", jw], t],
        "5-15": [w, j, t],
        "5-16": [["九毒日", jw], ["天地元气造化万物之辰", jw]],
        "5-17": [j],
        "5-18": [["张天师诞"]],
        "5-22": [["孝娥神诞", dj]],
        "5-23": [t],
        "5-25": [j, h],
        "5-26": [j],
        "5-27": [j, d],
        "5-28": [r],
        "5-29": [t],
        "5-30": [hh, m, t],
        "6-1": [s],
        "6-3": [["韦驮菩萨圣诞"], d, y],
        "6-5": [["南赡部洲转大轮", ss]],
        "6-6": [["天地仓开日", ss], l],
        "6-8": [t],
        "6-10": [["金粟如来诞"]],
        "6-14": [t],
        "6-15": [w, t],
        "6-19": [["观世音菩萨成道", dj]],
        "6-23": [["南方火神诞", "犯者遭回禄"], t],
        "6-24": [["雷祖诞", xl], ["关帝诞", xl]],
        "6-25": [h],
        "6-27": [d],
        "6-28": [r],
        "6-29": [t],
        "6-30": [hh, m, t],
        "7-1": [s, y],
        "7-3": [d],
        "7-5": [["中会日", ss, "", "一作初七"]],
        "7-6": [l],
        "7-7": [["道德腊", xl], ["五帝校生人善恶", xl], ["魁星诞", xl]],
        "7-8": [t],
        "7-10": [["阴毒日", "", "", "大忌"]],
        "7-12": [["长真谭真人诞"]],
        "7-13": [["大势至菩萨诞", js]],
        "7-14": [["三元降", js], t],
        "7-15": [w, ["三元降", dj], ["地官校籍", dj], t],
        "7-16": [["三元降", js]],
        "7-18": [["西王母诞", dj]],
        "7-19": [["太岁诞", dj]],
        "7-22": [["增福财神诞", xl]],
        "7-23": [t],
        "7-25": [h],
        "7-27": [d],
        "7-28": [r],
        "7-29": [y, t],
        "7-30": [["地藏菩萨诞", dj], hh, m, t],
        "8-1": [s, ["许真君诞"]],
        "8-3": [d, ["北斗诞", xl], ["司命灶君诞", "犯者遭回禄"]],
        "8-5": [["雷声大帝诞", dj]],
        "8-6": [l],
        "8-8": [t],
        "8-10": [["北斗大帝诞"]],
        "8-12": [["西方五道诞"]],
        "8-14": [t],
        "8-15": [w, ["太明朝元", "犯者暴亡", "", "宜焚香守夜"], t],
        "8-16": [["天曹掠刷真君降", "犯者贫夭"]],
        "8-18": [["天人兴福之辰", "", "", "宜斋戒，存想吉事"]],
        "8-23": [["汉恒候张显王诞"], t],
        "8-24": [["灶君夫人诞"]],
        "8-25": [h],
        "8-27": [d, ["至圣先师孔子诞", xl], y],
        "8-28": [r, ["四天会事"]],
        "8-29": [t],
        "8-30": [["诸神考校", "犯者夺算"], hh, m, t],
        "9-1": [s, ["南斗诞", xl], ["北斗九星降世", dj, "", "此九日俱宜斋戒"]],
        "9-3": [d, ["五瘟神诞"]],
        "9-6": [l],
        "9-8": [t],
        "9-9": [["斗母诞", xl], ["酆都大帝诞"], ["玄天上帝飞升"]],
        "9-10": [["斗母降", dj]],
        "9-11": [["宜戒"]],
        "9-13": [["孟婆尊神诞"]],
        "9-14": [t],
        "9-15": [w, t],
        "9-17": [["金龙四大王诞", "犯者遭水厄"]],
        "9-19": [["日宫月宫会合", js], ["观世音菩萨诞", js]],
        "9-23": [t],
        "9-25": [h, y],
        "9-27": [d],
        "9-28": [r],
        "9-29": [t],
        "9-30": [["药师琉璃光佛诞", "犯者危疾"], hh, m, t],
        "10-1": [s, ["民岁腊", dj], ["四天王降", "犯者一年内死"]],
        "10-3": [d, ["三茅诞"]],
        "10-5": [["下会日", js], ["达摩祖师诞", js]],
        "10-6": [l, ["天曹考察", dj]],
        "10-8": [["佛涅槃日", "", "", "大忌色欲"], t],
        "10-10": [["四天王降", "犯者一年内死"]],
        "10-11": [["宜戒"]],
        "10-14": [["三元降", js], t],
        "10-15": [w, ["三元降", dj], ["下元水府校籍", dj], t],
        "10-16": [["三元降", js], t],
        "10-23": [y, t],
        "10-25": [h],
        "10-27": [d, ["北极紫徽大帝降"]],
        "10-28": [r],
        "10-29": [t],
        "10-30": [hh, m, t],
        "11-1": [s],
        "11-3": [d],
        "11-4": [["至圣先师孔子诞", xl]],
        "11-6": [["西岳大帝诞"]],
        "11-8": [t],
        "11-11": [["天地仓开日", dj], ["太乙救苦天尊诞", dj]],
        "11-14": [t],
        "11-15": [["月望", "上半夜犯男死 下半夜犯女死"], ["四天王巡行", "上半夜犯男死 下半夜犯女死"]],
        "11-17": [["阿弥陀佛诞"]],
        "11-19": [["太阳日宫诞", "犯者得奇祸"]],
        "11-21": [y],
        "11-23": [["张仙诞", "犯者绝嗣"], t],
        "11-25": [["掠刷大夫降", "犯者遭大凶"], h],
        "11-26": [["北方五道诞"]],
        "11-27": [d],
        "11-28": [r],
        "11-29": [t],
        "11-30": [hh, m, t],
        "12-1": [s],
        "12-3": [d],
        "12-6": [["天地仓开日", js], l],
        "12-7": [["掠刷大夫降", "犯者得恶疾"]],
        "12-8": [["王侯腊", dj], ["释迦如来成佛之辰"], t, ["初旬内戊日，亦名王侯腊", dj]],
        "12-12": [["太素三元君朝真"]],
        "12-14": [t],
        "12-15": [w, t],
        "12-16": [["南岳大帝诞"]],
        "12-19": [y],
        "12-20": [["天地交道", "犯者促寿"]],
        "12-21": [["天猷上帝诞"]],
        "12-23": [["五岳诞降"], t],
        "12-24": [["司今朝天奏人善恶", "犯者得大祸"]],
        "12-25": [["三清玉帝同降，考察善恶", "犯者得奇祸"], h],
        "12-27": [d],
        "12-28": [r],
        "12-29": [["华严菩萨诞"], t],
        "12-30": [["诸神下降，察访善恶", "犯者男女俱亡"]],
    ]

    public static var OTHER_FESTIVAL: [String: [String]] = [
        "1-1": ["弥勒菩萨圣诞"],
        "1-6": ["定光佛圣诞"],
        "2-8": ["释迦牟尼佛出家"],
        "2-15": ["释迦牟尼佛涅槃"],
        "2-19": ["观世音菩萨圣诞"],
        "2-21": ["普贤菩萨圣诞"],
        "3-16": ["准提菩萨圣诞"],
        "4-4": ["文殊菩萨圣诞"],
        "4-8": ["释迦牟尼佛圣诞"],
        "4-15": ["佛吉祥日"],
        "4-28": ["药王菩萨圣诞"],
        "5-13": ["伽蓝菩萨圣诞"],
        "6-3": ["韦驮菩萨圣诞"],
        "6-19": ["观音菩萨成道"],
        "7-13": ["大势至菩萨圣诞"],
        "7-15": ["佛欢喜日"],
        "7-24": ["龙树菩萨圣诞"],
        "7-30": ["地藏菩萨圣诞"],
        "8-15": ["月光菩萨圣诞"],
        "8-22": ["燃灯佛圣诞"],
        "9-9": ["摩利支天菩萨圣诞"],
        "9-19": ["观世音菩萨出家"],
        "9-30": ["药师琉璃光佛圣诞"],
        "10-5": ["达摩祖师圣诞"],
        "10-20": ["文殊菩萨出家"],
        "11-17": ["阿弥陀佛圣诞"],
        "11-19": ["日光菩萨圣诞"],
        "12-8": ["释迦牟尼佛成道"],
        "12-23": ["监斋菩萨圣诞"],
        "12-29": ["华严菩萨圣诞"],
    ]

    public class func getXiu(month: Int, day: Int) -> String {
        XIU_27[(XIU_OFFSET[abs(month) - 1] + day - 1) % XIU_27.count]
    }
}
